package main;

import com.trolltech.qt.core.Qt;
import com.trolltech.qt.gui.QListWidget;
import com.trolltech.qt.gui.QMouseEvent;
import com.trolltech.qt.gui.QWidget;
 
public class CustomListWidget extends QListWidget {

	public CustomListWidget() {
		super();
	}

	public CustomListWidget(QWidget parent) {
		super(parent);
	}

	public CustomListWidget(QPrivateConstructor arg0) {
		super(arg0);
	}

	@Override
	protected void mousePressEvent(QMouseEvent event) {
		if (event.button() == Qt.MouseButton.LeftButton){
			if (itemAt(event.pos()) != null){
				itemAt(event.pos()).setSelected(true);
				itemPressed.emit(itemAt(event.pos()));
			}
		} else {
			if (itemAt(event.pos()) != null){
				itemAt(event.pos()).setSelected(true);
				customContextMenuRequested.emit(event.pos());
			}
		}
	}
}